AC_INIT([cexpert], [0.11.0], [m0riarty@ya.ru])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CXX
#AC_PROG_RANLIB
AC_PROG_LIBTOOL


AC_MSG_CHECKING([whether Python support is requested])
AC_ARG_ENABLE(python,
	      AS_HELP_STRING([--enable-python],[Enable python support (default = yes)]),
	            [enable_python=$enableval have_python=$enableval],
              [enable_python=autodetect have_python=yes])
AC_MSG_RESULT([$enable_python])

if test "x$have_python" != "xno"; then
    AM_PATH_PYTHON([2.4],[],[no])
    if test "x$PYTHON" = "x:"; then
        have_python=no
    fi
fi

if test "x$have_python" != "xno"; then
    AC_PATH_PROG(PYTHON_CONFIG, python-config)
fi
AC_PATH_PROG(PHP_CONFIG, php-config)

if test "x$have_python" != "xyes"; then
    if test "x$enable_python" = "xyes"; then
        AC_MSG_ERROR([Python not found])
    fi
elif test "x$enable_python" != "xno"; then
    enable_python=yes
    AC_DEFINE([ENABLE_PYTHON],[1],[Define to compile with python support])
fi

AM_CONDITIONAL([ENABLE_PYTHON],[test "x$enable_python" = "xyes"])

AC_CONFIG_HEADERS([config.h])

AC_CONFIG_FILES([
 Makefile
 src/Makefile
 src/drivers/Makefile
 include/Makefile
 cexpert.d/Makefile
 init.d/Makefile
 tests/Makefile
 interfaces/Makefile
 interfaces/C/Makefile
 interfaces/python/Makefile
 interfaces/php/Makefile
])

AC_HEADER_SYS_WAIT
AC_HEADER_TIME

AC_CHECK_HEADER([mysql/mysql.h], , AC_MSG_ERROR([can't find mysql.h header]))

AC_FUNC_FORK
AC_FUNC_MMAP

AC_CHECK_LIB([mysqlclient_r], [mysql_init], , AC_MSG_ERROR(can't find mysqlclient_r library))
AC_CHECK_LIB([rt], [shm_open])


AC_OUTPUT
